<?php
require_once '../libs/app.config.php';
session_start();
if($_SESSION['LoginId'] == false){
	header("Location:login.php");
}
$tpn = new Page();
//分类列表
$sql="select * from adv_position order by id desc";
$query=$tpm->query($sql);
$totals=$tpm->num_rows($query);
	$tpn->pageft($totals,10);
	$result=$tpm->query($sql." limit ".$tpn->getfirstcount().",10");
while($rows=$tpm->fetch_array($result))
{

$adv_list[]=array('id'=>$rows['id'],
				  'position_name'=>$rows['position_name'],
			      'adv_width'=>$rows['adv_width'],
				  'adv_height'=>$rows['adv_height'],
				  'position_desc'=>$rows['position_desc']
				 );
}

//多项删除
if($_POST['submit'])
{
	if(!empty($_POST['check']))
	{
		$array=$_POST['check'];
		$arr=implode(',',$array);
		$id=explode(',',$arr);
		$size=count($id);
		for($j=0;$j<$size;$j++)
		{
			$sql="delete from adv_position where id='".$id[$j]."'";
			$query=$tpm->query($sql);
			if($query>0)
			echo "<script>alert('删除成功');history.back();</script>";
		}
	}
}

//单项删除
if($_POST['delid'])
{
  $sql="delete from adv_position where id='".$_POST['delid']."'";
  $query=$tpm->query($sql);
  if($query>0)
  echo "1";
  else
  echo "0";
}

require_once(INCLUDE_PATH.'template.inc.php');  //模板类及对象$tpl的加载
$tpl->assign("adv_list",$adv_list);
$tpl->assign('pages',$tpn->getpagenav());
$tpl->display("adv_position_list.html");
?>